package com.group.model;

import java.util.Random;

public class BrainRobot {

	private Long id;

	/**
	 * 昵称
	 */
	private String name;

	/**
	 * 头像
	 */
	private String headimage;

	/**
	 * 答题最短时间
	 */
	private Integer minTime;

	/**
	 * 答题最长时间
	 */
	private Integer maxTime;

	/**
	 * 此题目答题时间
	 */
	private Integer time;

	/**
	 * 答题正确率 0-100
	 */
	private Integer winRate;

	private Random r = new Random();

	/**
	 * 初始化高级机器人
	 */
	public void initMax() {
		winRate = 70;
		minTime = 1;
		maxTime = 5;
	}

	public void initMid() {
		winRate = 50;
		minTime = 2;
		maxTime = 7;
	}

	public void initLow() {
		winRate = 30;
		minTime = 3;
		maxTime = 9;
	}

	public void initRandom() {
		int i = r.nextInt(10);
		if (i == 0) {
			initMax();
		} else if (i >= 1 && i <= 3) {
			initMid();
		} else {
			initLow();
		}
	}

	/**
	 * 随机答题时间
	 */
	public void randomTime() {

		time = r.nextInt(maxTime - minTime) + minTime;
	}

	/**
	 * 答题
	 */
	public String answer(BrainQuestion question) {
		// 答题后随机下一次答题时间
		randomTime();
		if (r.nextInt(100) <= winRate) {
			// 答对
			return question.getRight();
		} else {
			// 打错
			return question.getWrong();
		}

	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getHeadimage() {
		return headimage;
	}

	public void setHeadimage(String headimage) {
		this.headimage = headimage;
	}

	public Integer getMinTime() {
		return minTime;
	}

	public void setMinTime(Integer minTime) {
		this.minTime = minTime;
	}

	public Integer getMaxTime() {
		return maxTime;
	}

	public void setMaxTime(Integer maxTime) {
		this.maxTime = maxTime;
	}

	public Integer getWinRate() {
		return winRate;
	}

	public void setWinRate(Integer winRate) {
		this.winRate = winRate;
	}

	public Integer getTime() {
		return time;
	}

	public void setTime(Integer time) {
		this.time = time;
	}

}
